package com.sqsf.controller;

import com.sqsf.common.QueryPageParam;
import com.sqsf.common.Result;
import com.sqsf.entity.Student;
import com.sqsf.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RequestMapping("/user")
@RestController
public class StudentController {
    @Autowired
    private StudentService studentService;

    @GetMapping("/list")
    public Result list(){
        List<Student> studentList = studentService.getAll();
        return Result.suc(studentList);
    }

    @PostMapping("/listPage")
    public Result listPage(@RequestBody QueryPageParam queryPageParam) {

        return studentService.listPage(queryPageParam);
    }
    @GetMapping("/findById/{id}")
    public Result findById(@PathVariable String id) {
        return studentService.findById(id);
    }

    @PostMapping("/save")
    public Result save(@RequestBody Student student) {
        return studentService.save(student);
    }

    @PutMapping("/edit")
    public Result edit(@RequestBody Student student) {
        return studentService.edit(student);
    }
}
